package com.zzh.service;

import com.zzh.framework.*;

/**
 * @ClassName UserService
 * @date 2021/4/5 19:57
 * @Version 1.0
 * @Description //模仿spring逻辑
 * @USER root
 */
@Component("UserService")
public class UserService implements BeanNameAware, InitializingBean {

    @Autowired
    private OrderService orderService;

    private String beanName;


    //可以知道当前spring为bean创建的bean的名字
    @Override
    public void setBeanName(String name) {
        this.beanName = name;
    }

    @Override
    public void afterPropertiesSet() {
        //验证bean内的属性是否初始化完毕
        if (orderService == null) {
            throw new NullPointerException();
        }
    }
    public void test(){
        System.out.println(orderService);
        System.out.println(beanName);
    }
}
